#include<bits/stdc++.h>
using namespace std;
#define int long long
int p[10006],d[100006],v[100006],a[100006],L,Vm,n,m;
bool chaosu(int d,int v,int a){
    if(a==0){
        if(v>Vm&&d<=p[m]){
            return true;
        }
    }
    if(a>0){
        double t=(Vm-v)/a;
        double x=v*t+a*t*t/2;
        if(x<=p[m])return true;
    }
    if(a<0){
        if(v>Vm&&d<=p[m]){
            return true;
        }
    }
    return false;
}

signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    scanf("%lld",&T);
    for(int i=1;i<=T;i++){
        memset(d,0,sizeof(d));
        memset(v,0,sizeof(v));
        memset(a,0,sizeof(a));
        int n,m,L,Vm;
        scanf("%lld %lld %lld %lld",&n,&m,&L,&Vm);
        for(int j=1;j<=n;j++){
                scanf("%lld %lld %lld",&d[j],&v[j],&a[j]);
        }
        for(int j=1;j<=m;j++){
            scanf("%lld",&p[j]);
        }
        int sum=0;
            int sta=1;
            int ans=0;
            for(int j=1;j<=n;j++){
                if(chaosu(d[j],v[j],a[j])){
                        for(int k=1;k<=m;k++){
                            if(p[k]>=d[j])sta=k;
                            break;
                        }
                }
                if(v[j]>Vm&&d[j]<=p[m]){
                    ans++;   
                }
            }
            sum=m-sta;
            cout<<ans<<" "<<sum<<endl;
    }
    return 0;
}
